CMAKE_FLAGS			+= -DCMAKE_BUILD_TYPE=Debug

MACHINE_X86_64		= x86_64

NINJA_BUILD			:= $(shell ninja --version 2> /dev/null)

ifdef NINJA_BUILD
	CMAKE_GENERATOR ?= "Ninja"
	MAKER = ninja
	SILENT =
else
	CMAKE_GENERATOR ?= "Unix Makefiles"
	MAKER = make
	SILENT = --silent
endif

all: $(MACHINE_X86_64)

mkbuild_$(MACHINE_X86_64):
	@if [ ! -e $(PWD)/build/$(MACHINE_X86_64)/CMakeCache.txt ]; \
	then \
		mkdir -p $(PWD)/build/$(MACHINE_X86_64)/; \
	fi

$(MACHINE_X86_64): mkbuild_$(MACHINE_X86_64)
	@cp ./tools/env/* build/$(MACHINE_X86_64)/
	@python ./tools/python/PyMaker.py $(MACHINE_X86_64)
	@cd build/$(MACHINE_X86_64) && cmake ../../ -G$(CMAKE_GENERATOR) $(CMAKE_FLAGS) && $(MAKER) ${SILENT}

clean:
	@rm -rf build/
